package com.neu.netty;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author 杜佳辉
 * @version 1.0
 * @date 2024-12-04-11:09
 */
public class HandlerServerHello extends SimpleChannelInboundHandler<ByteBuf> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
        System.out.println("Server received: " + msg.toString(io.netty.util.CharsetUtil.UTF_8));
        ctx.writeAndFlush(msg);
    }
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception{
        cause.printStackTrace();
        ctx.close();
    }
}
